package com.zhong.gang.applib.utils;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.PagerAdapter;

import java.util.List;

public class ViewPagerAdapter extends FragmentPagerAdapter {
    private List<Fragment> fragments;

    public ViewPagerAdapter(@NonNull FragmentManager fm,List<Fragment> list) {
        super(fm, FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.fragments = list;
    }

    @Override
    public int getItemPosition(Object object) {
        //注意：默认是PagerAdapter.POSITION_UNCHANGED，不会重新加载
        return PagerAdapter.POSITION_NONE;
    }

    @Override
    public Fragment getItem(int position) {
        Log.e("MYAJIN","===========================================================");
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

}